package com.pearl.sharding.level.table.demo.algorithm;

import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;

import java.util.Properties;

/**
 * @author TD
 * @version 1.0
 * @date 2024/2/23
 */
public class CustomKeyGenerateAlgorithm implements KeyGenerateAlgorithm {

    // 自定义算法的属性
    private boolean asString;

    // 初始化属性
    public void init(Properties props) {
        this.asString = Boolean.parseBoolean(props.getProperty("as-string", Boolean.FALSE.toString()));
    }

    public String generateKey() {
        // 自定义生成逻辑
        String id = "";
        return id;
    }

    public String getType() {
        return "CUSTOM";
    }
}
